<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\modules\home\models\ConsultSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '咨询列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<style type="text/css">
    th,td {text-align: center;}
</style>
<div class="consult-index">

    <!-- <p>
        <?= Html::a('Create Consult', ['create'], ['class' => 'btn btn-success']) ?>
    </p> -->

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\ActionColumn'],

            [
                'attribute' => 'id',
                'value' => 'id',
                'headerOptions' => ['width' => '50'],
            ],
            'usename',
            'phone',
            'question',
            [
                'format' => 'raw',
                'attribute' => 'status',
                'value' => function($model) {
                    if($model->status==0){
                        return "<a href='/home/consult/change-sta?id=".$model->id."'><span class='btn btn-info btn-xs'>未处理<span></a>";
                    }elseif($model->status==1){
                        return "<a href='/home/consult/change-sta?id=".$model->id."'><span class='btn btn-success btn-xs'>已处理<span></a>";
                    }else{
                        return "";
                    }
                },
                'filter' => ['0' => '未受理','1' => '已受理'],
            ],
            [
                'format' => 'raw',
                'attribute' => 'update_at',
                'value' => function($model) {
                    return date('Y-m-d H:i', $model->update_at);
                },
            ],
        ],
    ]); ?>


</div>
